package com.ruoyi.web.service.impl;

import java.util.List;

import com.ruoyi.web.utils.UserMsgUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.mapper.HistoryMapper;
import com.ruoyi.web.domain.History;
import com.ruoyi.web.service.IHistoryService;

/**
 * historyService业务层处理
 *
 * @author ruoyi
 * @date 2024-04-27
 */
@Service
public class HistoryServiceImpl implements IHistoryService {
    @Autowired
    private HistoryMapper historyMapper;

    /**
     * 查询history
     *
     * @param id history主键
     * @return history
     */
    @Override
    public History selectHistoryById(Long id) {
        return historyMapper.selectHistoryById(id);
    }

    /**
     * 查询history列表
     *
     * @param history history
     * @return history
     */
    @Override
    public List<History> selectHistoryList(History history) {
        if (UserMsgUtil.getUserId() != null) {
            history.setUserId(UserMsgUtil.getUserId());
        }
        return historyMapper.selectHistoryList(history);
    }

    /**
     * 新增history
     *
     * @param history history
     * @return 结果
     */
    @Override
    public int insertHistory(History history) {
        if (UserMsgUtil.getUserId() != null) {
            history.setUserId(UserMsgUtil.getUserId());
        }
        return historyMapper.insertHistory(history);
    }

    /**
     * 修改history
     *
     * @param history history
     * @return 结果
     */
    @Override
    public int updateHistory(History history) {
        return historyMapper.updateHistory(history);
    }

    /**
     * 批量删除history
     *
     * @param ids 需要删除的history主键
     * @return 结果
     */
    @Override
    public int deleteHistoryByIds(Long[] ids) {
        return historyMapper.deleteHistoryByIds(ids);
    }

    /**
     * 删除history信息
     *
     * @param id history主键
     * @return 结果
     */
    @Override
    public int deleteHistoryById(Long id) {
        return historyMapper.deleteHistoryById(id);
    }
}
